<template>
  <div id="index">
    <van-nav-bar title="贝壳找房"/>
    <router-view></router-view>
    <van-tabbar v-model="active" @change="changeMethod">
      <van-tabbar-item icon="home-o">首页</van-tabbar-item>
      <van-tabbar-item icon="search">搜索</van-tabbar-item>
      <van-tabbar-item icon="friends-o">朋友</van-tabbar-item>
      <van-tabbar-item icon="setting-o">我的</van-tabbar-item>
    </van-tabbar>
  </div>
</template>

<script>
export default {
  name: "index",
  data() {
    return {
      active: 0,
    };
  },
  mounted() {
     
    var login = this.$store.getters.selectlogin;

    if(login) {

       alert("欢迎访问")
    
    } else {
       
       alert("未登录, 请前往登录")

       this.$router.push("/")
    }
  },
  methods: {
    changeMethod(index) {
      if (index === 0) {
        this.$router.push("/home");
      } else if (index === 1) {
        this.$router.push("/search");
      } else if (index === 2) {
        this.$router.push("/friend");
      } else if (index === 3) {
        this.$router.push("/mine");
      }
    },
  },
};
</script>